package com.scsj.supermarket.view.activity.personalsettingmodel;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.scsj.supermarket.R;
import com.scsj.supermarket.view.activity.baseactivitymodel.BaseActivity;


/**
 * 修改性别
 */
public class ChangeSexActivity extends BaseActivity implements View.OnClickListener {

    private RelativeLayout man_rl,woman_rl,confidentiality_rl;
    private TextView man_tv,woman_tv,confidentiality_tv;
    private ImageView man_img,woman_img,confidentiality_img;
    private String sex;

    @Override
    protected void createView(Bundle savedInstanceState) {
        setContentView(R.layout.activity_change_sex);
    }

    private void RestureImg(){
        man_img.setVisibility(View.GONE);
        woman_img.setVisibility(View.GONE);
        confidentiality_img.setVisibility(View.GONE);
    }

    @Override
    protected void initView() {
        man_rl=findViewById(R.id.man_rl);
        woman_rl=findViewById(R.id.woman_rl);
        confidentiality_rl=findViewById(R.id.confidentiality_rl);
        man_tv=findViewById(R.id.man_tv);
        woman_tv=findViewById(R.id.woman_tv);
        confidentiality_tv=findViewById(R.id.confidentiality_tv);
        man_img=findViewById(R.id.man_img);
        woman_img=findViewById(R.id.woman_img);
        confidentiality_img=findViewById(R.id.confidentiality_img);
    }

    @Override
    protected void initListener() {
        man_rl.setOnClickListener(this);
        woman_rl.setOnClickListener(this);
        confidentiality_rl.setOnClickListener(this);
        man_tv.setOnClickListener(this);
    }

    @Override
    protected void initData() {

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.man_rl:
                RestureImg();
                man_img.setVisibility(View.VISIBLE);
                sex=man_tv.getText().toString();
                break;
            case R.id.woman_rl:
                RestureImg();
                woman_img.setVisibility(View.VISIBLE);
                sex=woman_tv.getText().toString();
                break;
            case R.id.confidentiality_rl:
                RestureImg();
                confidentiality_img.setVisibility(View.VISIBLE);
                sex=confidentiality_tv.getText().toString();
                break;
            case R.id.returnImg:
                Intent intent = getIntent();
                Bundle bundle = intent.getExtras();
                bundle.putString("sex", sex);//添加要返回给页面1的数据
                intent.putExtras(bundle);
                setResult(Activity.RESULT_OK, intent);//返回页面1
                finish();
                break;
        }
    }
}
